package com.dy.placeOrder2.service.impl;

import com.dy.pojo.Orders;
import com.dy.placeOrder2.mapper.OrdersMapper;
import com.dy.placeOrder2.service.OrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

    @Override
    public List<Orders> listOrdersByStatus(String status) {
        return ordersMapper.listOrdersByStatus(status);
    }

    @Override
    public List<Orders> listOrdersByBq(String bq, List<Orders> orders) {
        System.out.println("____________________________________________" + bq);
        List<Orders> result = new ArrayList<>();
        List<Orders> allOrders = ordersMapper.listOrdersByBq(bq);
        if (allOrders == null || allOrders.isEmpty()) {
            System.out.println("allOrders is empty or null");
        }
        System.out.println("allOrders: " + allOrders);
        System.out.println("orders: " + orders);

        for (Orders order : allOrders) {
            for (Orders order1 : orders) {
                if (order.getId().intValue() == (order1.getId()).intValue()) {
                    result.add(order);
                    break;
                }
            }
        }
        System.out.println("result: " + result);
        return result;
    }

    @Override
    public List<Orders> listAll() {
        return ordersMapper.listAll();
    }
}
